import { BaseTemplate, TemplateCategory } from '../types/template.types';

// 模板类型定义
export const TEMPLATE_CATEGORIES: TemplateCategory[] = [
    {
        code: 'text2img',
        name: '文生图',
        description: '通过文字描述生成图像',
        icon: 'text-to-image',
        sort_order: 1
    },
    {
        code: 'img2img',
        name: '图生图',
        description: '通过输入图片生成新图像',
        icon: 'image-to-image',
        sort_order: 2
    },
    {
        code: 'text2video',
        name: '文生视频',
        description: '通过文字描述生成视频',
        icon: 'text-to-video',
        sort_order: 3
    },
    {
        code: 'img2video',
        name: '图生视频',
        description: '通过输入图片生成视频',
        icon: 'image-to-video',
        sort_order: 4
    }
];

// 基础模板配置
export const BASE_TEMPLATES: Record<string, BaseTemplate> = {
    text2img: {
        name: '标准文生图',
        category: 'text2img',
        description: '通过文字描述生成图像的标准工作流',
        workflow_json: {
            nodes: {
                prompt_positive: {
                    type: 'CLIPTextEncode',
                    inputs: {
                        text: '{{prompt}}',
                        clip: '{{clip}}'
                    }
                },
                prompt_negative: {
                    type: 'CLIPTextEncode',
                    inputs: {
                        text: '{{negative_prompt}}',
                        clip: '{{clip}}'
                    }
                },
                sampler: {
                    type: 'KSampler',
                    inputs: {
                        seed: '{{seed}}',
                        steps: '{{steps}}',
                        cfg: '{{cfg_scale}}',
                        sampler_name: '{{sampler}}',
                        scheduler: '{{scheduler}}',
                        denoise: 1,
                        model: '{{model}}',
                        positive: '{{prompt_positive}}',
                        negative: '{{prompt_negative}}',
                        latent_image: '{{empty_latent}}'
                    }
                },
                decoder: {
                    type: 'VAEDecode',
                    inputs: {
                        samples: '{{sampler}}',
                        vae: '{{vae}}'
                    }
                }
            }
        },
        param_schema: {
            basic: [
                {
                    key: 'prompt',
                    label: '提示词',
                    type: 'string',
                    component: 'TextArea',
                    required: true,
                    description: '描述你想要生成的图像内容'
                },
                {
                    key: 'negative_prompt',
                    label: '反向提示词',
                    type: 'string',
                    component: 'TextArea',
                    description: '描述你不想在图像中出现的内容'
                },
                {
                    key: 'width',
                    label: '宽度',
                    type: 'number',
                    component: 'NumberInput',
                    default: 512,
                    props: {
                        min: 64,
                        max: 2048,
                        step: 64
                    }
                },
                {
                    key: 'height',
                    label: '高度',
                    type: 'number',
                    component: 'NumberInput',
                    default: 512,
                    props: {
                        min: 64,
                        max: 2048,
                        step: 64
                    }
                }
            ],
            advanced: [
                {
                    key: 'seed',
                    label: '随机种子',
                    type: 'number',
                    component: 'SeedInput',
                    default: -1
                },
                {
                    key: 'steps',
                    label: '采样步数',
                    type: 'number',
                    component: 'NumberInput',
                    default: 20,
                    props: {
                        min: 1,
                        max: 100
                    }
                },
                {
                    key: 'cfg_scale',
                    label: '提示词相关性',
                    type: 'number',
                    component: 'Slider',
                    default: 7,
                    props: {
                        min: 1,
                        max: 20,
                        step: 0.5
                    }
                },
                {
                    key: 'sampler',
                    label: '采样器',
                    type: 'string',
                    component: 'Select',
                    default: 'euler_a',
                    props: {
                        options: [
                            { label: 'Euler a', value: 'euler_a' },
                            { label: 'DPM++ 2M', value: 'dpm++_2m' }
                        ]
                    }
                }
            ]
        }
    },

    img2img: {
        name: '标准图生图',
        category: 'img2img',
        description: '通过输入图片生成新图像的标准工作流',
        workflow_json: {
            nodes: {
                image_loader: {
                    type: 'LoadImage',
                    inputs: {
                        image: '{{input_image}}'
                    }
                },
                vae_encoder: {
                    type: 'VAEEncode',
                    inputs: {
                        pixels: '{{image_loader}}',
                        vae: '{{vae}}'
                    }
                },
            }
        },
        param_schema: {
            basic: [
                {
                    key: 'input_image',
                    label: '输入图片',
                    type: 'image',
                    component: 'ImageUpload',
                    required: true
                },
                {
                    key: 'prompt',
                    label: '提示词',
                    type: 'string',
                    component: 'TextArea'
                },
                {
                    key: 'strength',
                    label: '变化程度',
                    type: 'number',
                    component: 'Slider',
                    default: 0.75,
                    props: {
                        min: 0,
                        max: 1,
                        step: 0.01
                    }
                }
            ],
            advanced: [
            ]
        }
    },

    text2video: {
        name: '标准文生视频',
        category: 'text2video',
        description: '通过文字描述生成视频的标准工作流',
        workflow_json: {
        },
        param_schema: {
            basic: [
                {
                    key: 'prompt',
                    label: '提示词',
                    type: 'string',
                    component: 'TextArea',
                    required: true
                },
                {
                    key: 'duration',
                    label: '视频时长(秒)',
                    type: 'number',
                    component: 'NumberInput',
                    default: 3,
                    props: {
                        min: 1,
                        max: 30
                    }
                },
                {
                    key: 'fps',
                    label: '帧率',
                    type: 'number',
                    component: 'Select',
                    default: 24,
                    props: {
                        options: [
                            { label: '24fps', value: 24 },
                            { label: '30fps', value: 30 }
                        ]
                    }
                }
            ]
        }
    },

    img2video: {
        name: '标准图生视频',
        category: 'img2video',
        description: '通过输入图片生成视频的标准工作流',
        workflow_json: {
        },
        param_schema: {
            basic: [
                {
                    key: 'input_image',
                    label: '输入图片',
                    type: 'image',
                    component: 'ImageUpload',
                    required: true
                },
                {
                    key: 'motion_scale',
                    label: '动作幅度',
                    type: 'number',
                    component: 'Slider',
                    default: 0.5,
                    props: {
                        min: 0,
                        max: 1,
                        step: 0.1
                    }
                },
                {
                    key: 'duration',
                    label: '视频时长(秒)',
                    type: 'number',
                    component: 'NumberInput',
                    default: 3
                }
            ]
        }
    }
}; 